<template>
  <div class="top_box">
    <div>
      <img style="height: 13rem" src="@/assets/home/left.png" alt="" />
    </div>
    <div style="width: 100%">
      <div style="
                      display: flex;
                      justify-content: space-between;
                      margin-top: 1rem;
                    ">
        <div class="title" style="
                        margin-left: 3rem;
                        font-size: 2rem;
                        font-weight: bold;
                      "></div>
        <!-- 正常过高过低样式 -->
        <div style="display: flex; margin-right: 2rem">
          <img style="width: 90%" src="@/assets/home/status.png" alt="" />
        </div>
      </div>

      <div class="box">
        <div class="item_box" v-for="(item, index) in sewageList" :key="index">
          <div>
            <i @click="showModal(item)" class="el-icon-s-data">
            </i>
          </div>
          <img src="" alt="" />
          <div style="
                          margin-bottom: 2rem;
                          align-items: center;
                          line-height: 1rem;
                        ">
            <div style="
                            margin-bottom: 1rem;
                            margin-top: -1rem;
                            color: #0386ff;
                            font-weight: bold;
                          ">
              {{ item.realDataConvert }}
              <span style="font-size: 1rem">{{
                                item.attributeSymbol
                            }}</span>
            </div>
            <div :class="item.deviceName.length > 7 ? 'hover_title' : ''" :data-title="item.deviceName" style="font-size: 1.3rem">{{
                                item.deviceName.length > 7 ? item.deviceName.slice(0, 7) + "..." : item.deviceName }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    sewageList: {
      type: Array,
      default: []
    }
  },
  methods: {
    showModal(item) {
      this.$emit('showModal', item)
    }
  }
}
</script>
<style lang="less" scoped>
// 鼠标移入清除省略号
.hover_title[data-title] {
  position: relative;

  // 样式：
  &:hover:after {
    opacity: 1;
    transition: all 0.1s ease 0.5s;
    visibility: visible;
  }

  // 背景的样式 位置 字体等
  &:after {
    content: attr(data-title);
    position: absolute;
    padding: 1px 10px;
    left: 60px;
    bottom: -2.8em;
    height: 2rem;
    line-height: 2rem;
    // right: 0.5rem;
    border-radius: 4px;
    color: #fff;
    background-color: rgba(80, 79, 79, 0.8);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.16);
    font-size: 14px;
    white-space: nowrap;
    visibility: hidden;
    opacity: 0;
  }
}

.box {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding-bottom: 2rem;

  .item_title {
    position: relative;
    text-align: center;
    font-size: 2rem;
    border-radius: 3px;
    margin-left: 2rem;
    width: 13rem;
    background-color: #4472c4;
    height: 6rem;
    line-height: 6rem;
    color: #ffffff;
    box-shadow: 1px 1px 4px 5px rgba(215, 234, 251, 0.6);
    border: 2px solid #9dd0fd;
    margin-top: 2rem;
  }

  .item_box {
    position: relative;
    text-align: center;
    font-size: 1.7rem;
    border-radius: 3px;
    margin-left: 2rem;
    width: 13rem;
    height: 6rem;
    box-shadow: 1px 1px 4px 5px rgba(215, 234, 251, 0.6);
    border: 2px solid #9dd0fd;
    margin-top: 2rem;

    .el-icon-s-data {
      color: #e2e2e4;
      position: absolute;
      right: 0.3rem;
      bottom: 0;
      cursor: pointer;
      font-size: 1.3rem;
    }
  }
}
</style>